package cz.mpelant.msoe.mealchecker.request;

import java.util.Calendar;
import java.util.Date;

import org.apache.http.client.methods.HttpUriRequest;

import android.content.Context;
import android.util.Log;

@SuppressWarnings("unused")
public class RequestHistory extends PostRequestType {
//	public static final String MEALS = "M31";
//	public static final String RAIDER = "S85";
//	public static final String SVC = "S51";
	public static final String ALL = "A_All_";

	private Context mCtx;
	private String type;
	private Calendar from;
	private Calendar to;

	public RequestHistory(Context ctx) {
		super("https://msoe.managemyid.com/student/svc_history_view.php");
		this.mCtx = ctx;
	}

	public RequestHistory(Context ctx, String type, Calendar from, Calendar to) {
		this(ctx);
		this.from = from;
		this.to = to;
		this.type = type;
	}

	public RequestHistory(Context ctx, String type) {
		this(ctx);

		from = Calendar.getInstance();
		from.add(Calendar.DATE, -14);
		to = Calendar.getInstance();
		
		this.type = type;
		Log.i("meal", from.toString());
	}

	public String getBody() {

		String s =  "FromMonth="
				+ (from.get(Calendar.MONTH)+1)
				+ "&FromDay="
				+ from.get(Calendar.DATE)
				+ "&FromYear="
				+ from.get(Calendar.YEAR)
				+ "&ToMonth="
				+ (to.get(Calendar.MONTH)+1)
				+ "&ToDay="
				+ to.get(Calendar.DATE)
				+ "&ToYear="
				+ to.get(Calendar.YEAR)
				+ "&plan="
				+ type
				+ "&submit=Submit";
		Log.d("meal", s);
		return s;
	}

	@Override
	public HttpUriRequest getHttpRequest() {
		addHeader("Referer", "https://msoe.managemyid.com/student/svc_history.php");
		addBody(getBody());
		return super.getHttpRequest();
	}

}
